<template>
  <view class="about-container">
    <!-- 导航栏 -->
    <u-navbar
      :leftText="'关于平台'"
      left-icon="arrow-left"
      left-icon-color="#303133"
      bg-color="#ffffff"
      fixed
      placeholder
      @left-click="back"
    >
    </u-navbar>

    <!-- 内容区域 -->
    <view class="content">
      <view style="background-color: #fff">
        <!-- 隐私政策 -->
        <view class="about-item" @click="goToPrivacyPolicy">
          <view class="item-text">隐私政策</view>
          <u-icon name="arrow-right" size="16" color="#909399" />
        </view>

        <!-- 用户协议 -->
        <view class="about-item" @click="goToUserAgreement">
          <view class="item-text">用户协议</view>
          <u-icon name="arrow-right" size="16" color="#909399" />
        </view>
      </view>
    </view>

    <!-- 底部退出登录按钮 -->
    <view class="logout-container">
      <u-button
        type="default"
        :customStyle="{
          backgroundColor: '#e5e5e5',
          color: '#909399',
          border: 'none',
          borderRadius: '10rpx',
          height: '90rpx',
          width: '50%',
          lineHeight: '90rpx',
          fontSize: '30rpx',
        }"
        @click="logout"
      >
        退出登录
      </u-button>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import { navigate as publicNavigate } from "@/utils/public.js";
const back = () => {
  publicNavigate("back");
};
// 初始化store和router

const router = useRouter();



// 返回上一页

// 显示更多选项
const showMoreOptions = () => {
  uni.showToast({
    title: "更多选项功能待实现",
    icon: "none"
  });
};

// 前往隐私政策
const goToPrivacyPolicy = () => {
  publicNavigate("/pages/my/privacyPolicy");
};

// 前往用户协议
const goToUserAgreement = () => {
   publicNavigate("/pages/my/userAgreement");
};

// 退出登录
const logout = () => {
  uni.showModal({
    title: "提示",
    content: "确定要退出登录吗？",
    success: (res) => {
      if (res.confirm) {
        // 清除用户信息
        uni.removeStorageSync("user");
        uni.removeStorageSync("userInfo");
        uni.removeStorageSync("isAdmin");
        uni.removeStorageSync("token");
        uni.reLaunch({
          url: "/pages/login/login",
        });
        // 跳转到登录页        
        //  publicNavigate("/pages/login/login");
      }
    },                                       
  });
};
</script>

<style scoped>
.about-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: rgba(248, 248, 248, 1);
}

.content {
  flex: 1;
  margin-top: 22rpx;
}

.about-item {
  background: #ffffff;
  display: flex;
  margin: 0 30rpx;
  justify-content: space-between;
  align-items: center;
  height: 100rpx;
  border-bottom: 1rpx solid #e4e7ed;
}

.item-text {
  font-size: 28rpx;
  color: #303133;
}

.logout-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 30rpx;
  display: flex;
  justify-content: center;
  z-index: 99;
  background-color: rgba(248, 248, 248, 1);
}

.right-icon-container {
  padding-right: 20rpx;
}
</style>